<template>
  <div style="min-height: 500px">
    <el-form label-width="120px" style="margin-bottom: 10px">
      <el-row :gutter="10">
        <el-col :span="4">
          <el-form-item label="创建人">
            <el-input v-model="state.sd.createUser" placeholder="创建人"/>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="查询时间起">
            <el-date-picker v-model="state.sd.startDate" type="date" placeholder="查询时间起" value-format="YYYY-MM-DD" />
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="查询时间止">
            <el-date-picker v-model="state.sd.endDate" type="date" placeholder="查询时间止" value-format="YYYY-MM-DD" />
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-button size="default" type="primary" class="ml5" @click="searchSnapshot">
            <el-icon><ele-Search /></el-icon>查询
          </el-button>
        </el-col>
      </el-row>
    </el-form>

    <el-table :data="state.ssObj.list" border style="width: 100%">
      <el-table-column label="标题" prop="title"></el-table-column>
      <el-table-column label="创建人" prop="createuser"></el-table-column>
      <el-table-column label="创建时间">
        <template v-slot="scope">
          <DateFormat :value="scope.row.createtime" :format="'YYYY-MM-DD HH:mm'"></DateFormat>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template v-slot="scope">
          <el-button size="small" type="primary" @click="viewSS(scope.row.id)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination class="mt15" background layout="total,sizes, prev, pager, next"
                   @current-change="loadSnapshot" @size-change="loadSnapshot" :total="state.ssObj.total"
                   v-model:current-page="state.sd.pageNum" v-model:page-size="state.sd.pageSize" :page-sizes="state.sd.pageSizes">
    </el-pagination>
  </div>
</template>

<script setup name="planRecord">
import request from '/@/utils/request';
import { ElMessage } from 'element-plus';
import mittBus from '/@/utils/mitt';
import {reactive, ref, onMounted, onUnmounted, defineAsyncComponent, defineProps} from "vue";
import { useRouter } from "vue-router";
const router = useRouter();

let props = defineProps({
  planId : {type : Number, default: 0}
})
const state = reactive({
  sd: {
    planId : 0,
    createUser:'',
    startDate:'',
    endDate:'',
    pageNum: 1,
    pageSize: 20,
    pageSizes: [10, 20, 50, 100],
  },
  ssObj: {},
})
const searchSnapshot = ()=>{
  state.sd.pageNum = 1;
  loadSnapshot();
}
const loadSnapshot = ()=>{
  request({
    url: '/cssnapshot/listcssnapshotplan',
    data: state.sd
  }).then(res => {
    const { data } = res
    state.ssObj = data
  })
}
const viewSS = (id)=>{
  router.push({name: 'kucunsnapshotView', params :{id : id} })
}
onMounted(()=>{
  state.sd.planId = props.planId
  loadSnapshot();
})
onUnmounted(()=>{

})
</script>

<style scoped>

</style>
